package com.wsl.Publisher;

import com.wsl.Event.DemoEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @Author:WangShuliang
 * @Description:
 * @Date:Created in 15:39 2017/11/24
 * @Modified by:
 */
@Component
public class DemoPublisher {
    //注入ApplicationContext用来发布事件
    @Autowired
    ApplicationContext applicationContext;

    public void publish(String msg){
        //使用ApplicationContext的publishEvent方法来发布
        applicationContext.publishEvent(new DemoEvent(this,msg));
    }
}